package offer;

/**
 * <p>
 * 剑指 Offer 28. 对称的二叉树
 * </p>
 *
 * @author xiaozuolin
 * @date 2021/9/23 16:12
 */
public class Offer28 {
    public boolean isSymmetric(TreeNode root) {
        return root == null ? true : recur(root.left, root.right);
    }

    public boolean recur(TreeNode L, TreeNode R) {
        if (L == null && R == null) {
            return true;
        }
        if (L == null || R == null || L.val != R.val) {
            return false;
        }
        return recur(L.left, R.right) && recur(L.right, R.left);
    }
}
